package com.liuyandog.server;

import com.liuyandog.pojo.*;
import javax.swing.*;
import javax.swing.table.TableModel;
import java.awt.*;

public class UserRecordServer extends UserUI {
    /*借阅记录界面*/
    JLabel lCount;
    JTable tBook;//表格，用于存放书籍借阅界面
    JButton bReturn;
    Font write;
    User user;

    //测试用例
    Object[] columnNames = {"书籍编号", "书籍名称", "书籍简介", "作者", "价格","书籍类别","出版社"};

    // 表格所有行数据
    Object[][] rowData = {
            {"张三", 80, 80, 80, 240,20,20},
            {"John", 70, 80, 90, 240,20,20},
            {"Sue", 70, 70, 70, 210,20,20},
            {"Jane", 80, 70, 60, 210,20,20},
            {"Joe", 80, 70, 60, 210,20,20}
    };
    public UserRecordServer(){
        super();
       // lCount = new JLabel("当前借书总数:" + user.count);
        setLayout(null);
        tBook = new JTable(rowData, columnNames);
        bReturn = new JButton("归还");
        write = new Font("宋体", Font.BOLD, 20);
        tBook.setFont(write);//设置表格字体
        tBook.setForeground(Color.BLACK);//设置字体颜色
        tBook.setSelectionForeground(Color.RED);//设置选中时的字体颜色
        tBook.setSelectionBackground(Color.BLUE);//设置选中时的行背景色

        bReturn.setFont(new Font("宋体", Font.BOLD, 20));
        bReturn.setBounds(100,300,150,30);
        /*
        tBook.setShowHorizontalLines(true);//显示水平方向的网格线
        tBook.setShowVerticalLines(false);//不显示垂直方向的网格线
        */
        tBook.setShowGrid(true);//设置网格可见
        tBook.setPreferredScrollableViewportSize(new Dimension(300,500));//设置滚动视窗
        JScrollPane sMove = new JScrollPane(tBook);//将滚动加入

        add(tBook.getTableHeader(),BorderLayout.NORTH);
        add(tBook, BorderLayout.CENTER);
        sMove.setVisible(true);//设置可见
        /*
        lCount.setBounds();
        */

        bReturn.addActionListener(this);
        //add(lCount);
        add(sMove);
        add(bReturn);
    }
}
